package com.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.CustomerBean;
import com.project.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("customer")
public class CustomerController {
    @Autowired
    private ICustomerService customerService;
    @RequestMapping("findByItem")
    public IPage<CustomerBean> findByItem(Integer pageNO, String name, String cusRange) {
      return   customerService.findByItem(pageNO, name, cusRange);
    }
    @RequestMapping("findById")
    public CustomerBean findById(Integer id){
        return customerService.findById(id);
    }
    @RequestMapping("update")
    public String update(Integer id, String leadingCadre, String phone, String cusRange){
        customerService.update(id, leadingCadre, phone, cusRange);
        return "ok";
    }
    @RequestMapping("add")
    public String add(CustomerBean customer){
        boolean flag = customerService.add(customer);
        if (flag){
            return "ok";
        }
        return "no";
    }
    @RequestMapping("findAll")
    public List<CustomerBean> findAll() {
        return customerService.findAll();
    }
}
